{% extends "admin/base_site_nav.html" %}
{% load rest_framework %}
{% load i18n %}

{% block extrahead %}{{block.super}}
<script src="{{STATIC_URL}}rest_framework/js/ajax-form.js"></script>
<script>

$(function() {
  $('form').ajaxForm();
});

</script>
{% endblock %}

{% block content %}
<div id="content-main">

<div id="request-info">
<br>
{% comment %}Translators: Translation included with Django {% endcomment %}
{% trans "HTTP request" %}:<b><br>
&nbsp;&nbsp;{{ request.method }}</b> {{request.prefix}}{{ request.get_full_path }}<br><br>
</div>

<div class="response-info">
{% comment %}Translators: Translation included with Django {% endcomment %}
{% trans "HTTP response headers" %}:<br>
&nbsp;&nbsp;<b>HTTP {{ response.status_code }} {{ response.status_text }}</b>
<br>
{% autoescape off %}
{% for key, val in response_headers.items %}<b>&nbsp;&nbsp;{{ key }}:&nbsp;&nbsp;</b>
{{ val|break_long_headers|urlize_quoted_links }}<br>
{% endfor %}
</div>

<div class="response-info" style="margin-top: 20px; margin-bottom: 20px">

{% comment %}Translators: Translation included with Django {% endcomment %}
{% trans "HTTP response content" %}:<br>
<textarea class='form-control' id="records" rows="20" style="width:100%">{{ content|urlize_quoted_links }}</textarea>
{% endautoescape %}
</div>

<div id="APIaccordion" class="panel-group" role="tablist" aria-multiselectable="true" style="max-width:100%">

{% if 'GET' in allowed_methods %}
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="eersteHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#html_raw" aria-expanded="true" aria-controls="html_raw">
              {% blocktrans with model=name %}Make a GET request to read {{ model }} object(s){% endblocktrans %}
        </a>
      </h4>
    </div>
      <div id="html_raw" class="panel-collapse collapse" role="tabpanel" aria-labelledby="eersteHeading">
        <div class="panel-body">
  {% if api_settings.URL_FORMAT_OVERRIDE %}
    {% for format in available_formats %}
							  <button  class="btn btn-primary" role="button" type="submit"
							    value="{{ format|upper }} {% blocktrans with http_method='GET' %}{{ http_method }} request{% endblocktrans %}"
							    onclick="window.location.href = '{{request.prefix}}{% add_query_param request api_settings.URL_FORMAT_OVERRIDE format %}'">{{ format|upper }} {% blocktrans with http_method='GET' %}{{ http_method }} request{% endblocktrans %}
							  </button>
    {% endfor %}
  {% else %}
					    <a href="{{request.prefix}}{{ request.get_full_path }}" rel="nofollow">
					    {% blocktrans with http_method='GET' %}{{ http_method }} request{% endblocktrans %}
              </a>
  {% endif %}
      </div>
    </div>
  </div>
{% endif %}

{% if options_form %}
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="twedeHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#options_get" aria-expanded="true" aria-controls="options_get">
              {% blocktrans with model=name %}Make an OPTIONS request to see all fields on the {{ model }} object{% endblocktrans %}
        </a>
      </h4>
    </div>
    <div id="options_get" class="panel-collapse collapse" role="tabpanel" aria-labelledby="twedeHeading">
      <div class="panel-body">
		  <form class="button-form" action="{{request.prefix}}{{ request.get_full_path }}" data-method="OPTIONS">
		    <button  class="btn btn-primary" role="button" type="submit"
		      value="{% blocktrans with http_method='OPTIONS' %}{{ http_method }} request{% endblocktrans %}">
		      {% blocktrans with http_method='OPTIONS' %}{{ http_method }} request{% endblocktrans %}
		    </button>
		  </form>
      </div>
    </div>
  </div>
{% endif %}


{% if display_edit_forms %}
{% if post_form or raw_data_post_form %}
{% if post_form %}
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="derdeHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#post_form" aria-expanded="true" aria-controls="post_form">
              {% blocktrans with model=name %}Make a POST request using a HTML form to create a new {{ model }} object{% endblocktrans %}
        </a>
      </h4>
    </div>
    <div id="post_form" class="panel-collapse collapse" role="tabpanel" aria-labelledby="derdeHeading">
      <div class="panel-body">
        {% with form=post_form %}
        <form action="{{request.prefix}}{{ request.get_full_path }}" method="POST" enctype="multipart/form-data" novalidate>
	        {% csrf_token %}
          {{ post_form }}
	        <div class="form-actions">
	          <button  class="btn btn-primary" role="button" type="submit"
	             value="{% blocktrans with http_method='POST' %}{{ http_method }} request{% endblocktrans %}">
	             {% blocktrans with http_method='POST' %}{{ http_method }} request{% endblocktrans %}
	          </button>
	        </div>
        </form>
        {% endwith %}
     </div>
   </div>
   </div>
{% endif %}

    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="zevendeHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#post_form_raw" aria-expanded="true" aria-controls="post_form_raw">
              {% blocktrans with model=name %}Make a POST request in raw format to create a new {{ model }} object{% endblocktrans %}
        </a>
      </h4>
    </div>
    <div id="post_form_raw" class="panel-collapse collapse" role="tabpanel" aria-labelledby="zevendeHeading">
      <div class="panel-body">
        {% with form=raw_data_post_form %}
       <form action="{{request.prefix}}{{ request.get_full_path }}" method="POST" class="form-horizontal">
        {% include "rest_framework/raw_data_form.html" %}
        <div class="form-actions">
          <button  class="btn btn-primary" role="button" type="submit"
            value="{% blocktrans with http_method='POST' %}{{ http_method }} request{% endblocktrans %}">
            {% blocktrans with http_method='POST' %}{{ http_method }} request{% endblocktrans %}
          </button>
        </div>
       </form>
       {% endwith %}
     </div>
   </div>
   </div>
 {% endif %}

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="vierdeHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#put_form" aria-expanded="true" aria-controls="put_form">
              {% blocktrans with model=name %}Make a PUT request using a HTML form to update one {{ model }} object{% endblocktrans %}
        </a>
      </h4>
    </div>
    <div id="put_form" class="panel-collapse collapse" role="tabpanel" aria-labelledby="vierdeHeading">
      <div class="panel-body">
	      <form action="{{request.prefix}}{{ request.get_full_path }}" data-method="PUT" enctype="multipart/form-data" class="form-horizontal" novalidate>
          {{ put_form }}
	        <div class="form-actions">
	          <button  class="btn btn-primary" role="button" type="submit"
	           value="{% blocktrans with http_method='PUT' %}{{ http_method }} request{% endblocktrans %}">
	           {% blocktrans with http_method='PUT' %}{{ http_method }} request{% endblocktrans %}
	          </button>
	        </div>
	      </form>
      </div>
    </div>
  </div>

  {% if put_form or raw_data_put_form or raw_data_patch_form %}
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="vijfdeHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#put_patch_form" aria-expanded="true" aria-controls="put_patch_form">
              {% blocktrans with model=name %}Make a PUT or PATCH request in raw format to update one or more existing {{ model }} objects{% endblocktrans %}
        </a>
      </h4>
    </div>
    <div id="put_patch_form" class="panel-collapse collapse" role="tabpanel" aria-labelledby="vijfdeHeading">
      <div class="panel-body">
    {% with form=raw_data_put_or_patch_form %}
	      <form action="{{request.prefix}}{{ request.get_full_path }}" data-method="PUT" class="form-horizontal">
	    {% include "rest_framework/raw_data_form.html" %}
	        <div class="form-actions">
	      {% if raw_data_put_form %}
	            <button  class="btn btn-primary" role="button" type="submit"
	               value="{% blocktrans with http_method='PUT' %}{{ http_method }} request{% endblocktrans %}">
	               {% blocktrans with http_method='PUT' %}{{ http_method }} request{% endblocktrans %}
	            </button>
	      {% endif %}
	      {% if raw_data_patch_form %}
	            <button  class="btn btn-primary" role="button" type="submit" data-method="PATCH"
	               value="{% blocktrans with http_method='PATCH' %}{{ http_method }} request{% endblocktrans %}">
	               {% blocktrans with http_method='PATCH' %}{{ http_method }} request{% endblocktrans %}
	            </button>
	      {% endif %}
	        </div>
	      </form>
    {% endwith %}
      </div>
    </div>
  </div>
  {% endif %}

  {% if delete_form %}
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="zesdeHeading">
      <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#APIaccordion" href="#delete_form" aria-expanded="true" aria-controls="delete_form">
              {% blocktrans with model=name %}Make a DELETE request to delete one or more existing {{ model }} objects (requires filtering){% endblocktrans %}
        </a>
      </h4>
    </div>
    <div id="delete_form" class="panel-collapse collapse" role="tabpanel" aria-labelledby="zesdeHeading">
      <div class="panel-body">
          <form class="button-form" action="{{request.prefix}}{{ request.get_full_path }}" data-method="DELETE">
            <button  class="btn btn-primary" role="button" type="submit" data-method="DELETE"
                value="{% blocktrans with http_method='DELETE' %}{{ http_method }} request{% endblocktrans %}">
                {% blocktrans with http_method='DELETE' %}{{ http_method }} request{% endblocktrans %}
            </button>
        </form>
      </div>
    </div>
  </div>
  {% endif %}

{% endif %}
</div>
{% endblock %}


